package npcs

import (
	"fmt"
	"math"
)

func (loc Location) String() string{
	return fmt.Sprintf("X=>%f,Y=>%f,Z=>%f",loc.X,loc.Y,loc.Z)
}
//计算欧力距离
func (loc Location) EuclideabDistance(target Location) float64 {
	return 	math.Sqrt(
			(loc.X - target.X)*(loc.X - target.X)+
			(loc.Y - target.Y)*(loc.Y - target.Y)+
			(loc.Z - target.Z)*(loc.Z - target.Z))
}
//距离返回两个游戏角色之间的距离
func (npc NonPlayerCharacter) DistanceTo(target NonPlayerCharacter) float64{
	return npc.Loc.EuclideabDistance(target.Loc)
}

func (npc NonPlayerCharacter) String() string{
	return fmt.Sprintf("%s %s",npc.Name,npc.Loc)
}